const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const { defineConfig } = require('@vue/cli-service')


module.exports = defineConfig({
  publicPath: './',
  transpileDependencies: true,
  lintOnSave: false,
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  },
  chainWebpack: config => {
   config.when(process.env.NODE_ENV === 'production',config => {
    // 生产模式
    config.entry('app').clear().add('./src/main-prod.js')

    config.set('externals',{
      'echarts': 'echarts',
      vue: 'Vue',
      axios: 'axios',
    })
   });

   config.when(process.env.NODE_ENV === 'development',config => {
    // 开发模式
    config.entry('app').clear().add('./src/main-dev.js')
   });

  }
})
